import 'package:flutter/material.dart';

import 'HomePage.dart';
import 'PrettyPhotoPage.dart';
import 'MinePage.dart';

class MainPage extends StatefulWidget {
  const MainPage({super.key});

  @override
  MainPageState createState() => MainPageState();
}

class MainPageState extends State<MainPage> {
  final PageController pageController = PageController();
  final defaultColor = Colors.grey;
  final activeColor = Colors.blue;
  int _currentIndex = 0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: PageView(
        controller: pageController,
        children: [HomePage(), PrettyphotoPage(), MinePage()],
      ),
      bottomNavigationBar: BottomNavigationBar(
        currentIndex: _currentIndex,
        unselectedItemColor: defaultColor,
        selectedItemColor: activeColor,
        type: BottomNavigationBarType.fixed,
        items: [
          BottomNavigationBarItem(icon: Icon(Icons.home), label: '首页'),
          BottomNavigationBarItem(icon: Icon(Icons.photo_camera), label: '美图'),
          BottomNavigationBarItem(icon: Icon(Icons.account_box), label: '我的'),
        ],
        onTap: (index) {
          pageController.jumpToPage(index);
          setState(() {
            _currentIndex = index;
          });
        },
      ),
    );
  }
}
